<template>
	
	<div v-for="(item,index) in tableDataCopy">
		
		<el-checkbox  v-model="item[0].x" @change="addEmpId(item[0].liaEmpId,item[0].x)" :disabled="okrFlag">被考核人：{{item[0].name}}</el-checkbox>
		<br>
		<el-table
      :data="item"
      border
      style="width: 90%; margin: 20px auto;border-radius: 8px;box-shadow: 5px 5px 10px rgba(64, 158, 255, 0.5);"
      :header-cell-style="{
          'background': '#337ecc !important',
          'color': '#ffffff',
          'border': 'none !important'
        }">

    <el-table-column prop="target" label="关键事项描述" ></el-table-column>
	<el-table-column prop="assessorName" label="发布人" width="180" />
      <el-table-column prop="totalScore" label="O分值" width="100" ></el-table-column>
      <el-table-column prop="keyResult" label="要求达成的目标" ></el-table-column>
      <el-table-column prop="keyWeight" label="考核分数" width="80"></el-table-column>
      <el-table-column prop="ins" label="考核类型" width="150"/>
	  <el-table-column prop="name" label="执行人员姓名" width="180" />
	  <el-table-column prop="completionInstructions" label="完成情况说明" width="180" />
      <el-table-column prop="score" label="评分" width="100"></el-table-column>
	  <el-table-column prop="remark" label="评分说明" width="100"></el-table-column>
    </el-table>
		
	</div>
	
	
	
	
</template>

<script setup>
import {ref, onBeforeMount, reactive,getCurrentInstance,watch} from "vue";

let props = defineProps({
  okrList: {
    type: Array,
    required: true, //是否规定必须得有
  },
  empList4: {
    type: Array,
    required: true, //是否规定必须得有
  },
  update4: {
    type: Function,
    required: true, //是否规定必须得有
  },
  flag:{
    type: Number,
    required: false, //是否规定必须得有
  },
}) 

watch(props, (newValue, oldValue) => {
  tableData.value=newValue.okrList
  if(newValue.flag == 1){
  	  okrFlag = true
  }else{
  	  okrFlag = false
  }
},{ deep: true });  

var okrFlag = true

const Form = reactive([])
const tableData=ref(props.okrList)


var flag = 1
const tableDataCopy = []
var data = [];

for(let i = 0 ; i<tableData.value.length;i++){
	
	data.push(props.okrList[i])
	
	if(i+1<tableData.value.length && props.okrList[i].name != props.okrList[i+1].name){
		tableDataCopy.push(data)
		data = []
		flag++;
	}
	
}

tableDataCopy.push(data)


var empList = []

const addEmpId = (empId,x) =>{
	if(x){
		empList.push(empId)
	}else{
		empList.pop(empId)
	}
	props.update4(empList,"empList4")
	
}


</script>











<style lang="scss" scoped>
.el-card {
  border-radius: 10px;
}
.formWrapper{
    width: 100%;
    border: 2px solid #DCDFE6;
    margin: 20px 0;
    border-radius: 5px;
    .formTitle{
        height: 50px;
        font-weight: bold;
        color: #303133;
        font-size: 25px;
        text-align: center;
        line-height: 50px;
        border-bottom: #DCDFE6 1px solid;
    }

    .form{
        width: 1200px;
        margin: 20px auto;
        border-radius: 5px;
        .title {
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-start;/* 替代space-between布局方式 */
            .title_box{
                width: 200px;
                flex: 1;
                height: 50px;
                background-color: #337ECC;
                text-align: center;
                color: #fff;
                line-height: 50px;
                font-size: 20px;
            }
        }
        .centent {
            display: flex;
            flex-wrap: wrap;
            justify-content: flex-start;/* 替代space-between布局方式 */
            .centent_box{
                width: 200px;
                flex: 1;
                height: 50px;
                background-color: #79bbff;
                color: #fff;
                padding: 5px;
                line-height: 40px;
                text-align: center;
            }
        }
    }
    .button{
        width: 200px;
        height: 40px;
        margin: 10px auto;
        float: right;
    }
}
</style>
